package com.hotel.services.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hotel.daos.StaffMapper;
import com.hotel.entitys.Staff;
import com.hotel.services.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StaffServiceImpl implements StaffService {
    @Autowired
    private StaffMapper staffMapper;

    @Override
    public PageInfo<Staff> getAllStaff(Integer currentPage, Integer pageSize, String keyword) {
        PageHelper.startPage(currentPage,pageSize);
        List<Staff> list = staffMapper.selectAllStaff(keyword);
        PageInfo<Staff> pageInfo = new PageInfo<Staff>(list);
        return pageInfo;
    }

    @Override
    //登录 通过Staff的电话和密码
    public Staff getStaffByNameAndPwd(String Staff_telephone, String Staff_password) {
        return staffMapper.login(Staff_telephone,Staff_password);
    }

    @Override
    public int addStaff(Staff staff) {
        return staffMapper.insertStaff(staff);
    }

    @Override
    public Staff getStaffById(Integer staff_id) {
        return staffMapper.selectStaffById(staff_id);
    }

    @Override
    public int changeStaff(Staff staff) {
        return staffMapper.updateStaff(staff);
    }

    @Override
    public int deleteOne(Integer staff_id) {
        return staffMapper.deleteStaffById(staff_id);
    }

    @Override
    public int deleteMulti(Object[] ids) {
        return staffMapper.deleteStaffByIds(ids);
    }

    @Override
    public int selStaffByTel(String telephone) {
        return staffMapper.selStaffByTel(telephone);
    }

    @Override
    public List<Staff> selAllFix() {
        return staffMapper.selAllFix();
    }

    @Override
    public int updateLogin(Staff staff) {
        return staffMapper.updateLogin(staff);
    }
}
